package com.gzbsoft.sc.modules.app.controller;
import com.gzbsoft.sc.common.config.QiNiuConfig;
import com.gzbsoft.sc.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api("公用api")
@RestController
@RequestMapping("/common")
public class CommonController {
    private final QiNiuConfig qiNiuConfig;
    public CommonController(QiNiuConfig qiNiuConfig) {
        this.qiNiuConfig = qiNiuConfig;
    }
    @ApiOperation(value = "获取七牛上传图片的token", notes = "文件上传需自行集成七牛SDK")
    @ApiImplicitParam(name = "key", value = "文件名")
    @GetMapping("/qiniu/token/img")
    public R qiNiuImgToken(String key) {
        String tokenQiNiu = qiNiuConfig.getImgClientTokenQiNiu(key);
        return R.ok().setObj(tokenQiNiu);
    }
    @ApiOperation(value = "获取七牛上传视频的token", notes = "文件上传需自行集成七牛SDK")
    @ApiImplicitParam(name = "key", value = "文件名")
    @GetMapping("/qiniu/token/video")
    public R qiNiuVideoToken(String key) {
        String tokenQiNiu = qiNiuConfig.getVideoTokenQiNiu(key);
        return R.ok().setObj(tokenQiNiu);
    }
}
